<template>
  <jb-crud-page ref="pageRef" searchUrl="/aiFunctionParam/list" :conditions-align="'start'" :searchConditions="pageConditions"  :resetBtnShown="false" :pager="false" :editComponent="Edit">
     <template #conditions-form>
       <n-input v-model="pageConditions.keywords" placeholder="请输入名称" clearable />
     </template>
    <template #opt>
<!--      <jb-btn type="primary" ghost @click="pageRef.showEditModal('新增参数',{functionId:props.functionId})">新增参数</jb-btn>-->
<!--      <jb-btn :icon="Icons.RESET" type="primary" ghost>同步(保留描述)</jb-btn>-->
<!--      <jb-btn style="margin-left: 8px" :icon="Icons.RESET" type="error" ghost>同步(包括描述)</jb-btn>-->
    </template>
    <template #default="{list,tableStartIndex}">
      <jb-table :data="list"
                :start-index="tableStartIndex"
      >
        <jb-column type="seq" title="序号" width="60" fixed="left"></jb-column>
        <jb-column
            field="paramName"
            title="参数名"
            min-width="160"
            fixed="left"
        ></jb-column>
        <jb-column
            field="type"
            title="参数值类型"
            min-width="160"
        ></jb-column>
        <jb-column
            field="briefInfo"
            title="参数描述"
            min-width="160"
        >
        </jb-column>
        <jb-column
            field="defaultValue"
            title="默认值"
            min-width="160"
        >
        </jb-column>
        <jb-column
            field="required"
            title="是否必填"
            min-width="160"
            fixed="right"
        >
          <template #default="{ row }">
            <jb-switch v-model:value="row.required" :url="`/aiFunctionParam/toggleEnable/${row.id}`" @update:value="pageRef.loadData()"></jb-switch>
          </template>
        </jb-column>

        <jb-column title="操作" width="120" fixed="right">
          <template #default="{ row }">
            <jb-btn class="mx-8px" tip-text="编辑资源" secondary circle type="warning" :icon="Icons.EDIT" @click="pageRef.showEditModal('编辑参数',{id:row.id})"></jb-btn>
          </template>

        </jb-column>

      </jb-table>
    </template>
  </jb-crud-page>
</template>

<script setup>
import {Icons} from "@/constants/index.js";
import {useResetableData} from "@/hooks/common/use-resetable-data.js";
import Edit from "./cpns/edit.vue"
import {ref} from "vue";

const props = defineProps({
  functionId:String
})

const pageRef = ref(null)
const pageConditions = useResetableData({
  keywords:'',
  functionId:props.functionId
})
</script>


<style scoped>

</style>